package com.runa.monitor.platinterface.netservice.equipment.fail;
import com.runa.monitor.comm.dto.Node;
import com.runa.monitor.comm.dto.newComm.AsynResult;
import com.runa.monitor.platinterface.mqtt.MqttUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 2024/7/9 14:58
 * zhangYB
 */
@Slf4j
public class ErrorDriver extends BaseDriver<String> {

    public ErrorDriver(String serial, Integer timeout) {
        super(serial, timeout);
    }

    public static void addEuqQueueError(String task, String serial, List<Node> nodeList, String topic, String holdInfo) {
//        addEuqQueueError(task, serial, nodeList, topic, holdInfo, "入队报错");
    }

    private static void addEuqQueueError(String task, String serial, List<Node> nodeList, String topic, String holdInfo
            , String format, String... arguments) {
        if (null == topic) {
            return;
        }
        AsynResult asynResult = new AsynResult();
        asynResult.setCode(201);
        asynResult.setMsg(String.format(format.replaceAll("\\{}", "%s"), arguments));
        asynResult.setId(serial);
        asynResult.setHoldInfo(holdInfo);
        asynResult.setTask(task);
        asynResult.setIdentity(serial);
        for (Node node : nodeList) {
            asynResult.setIdentity(node.getId());
            MqttUtil.send(topic, asynResult);
        }
    }


}
